package main

import (
	"net/http"

	"github.com/gin-gonic/gin"

	"awesomeProject3/gin_start/ch06/proto"
)

func main() {
	router := gin.Default()
	router.GET("/moreJSON", moreJSON)
	router.GET("/someProtoBuf", returnProto)
	_=router.Run(":8083")
}

func returnProto(c *gin.Context) {
	course:=[]string{"python","go","微服务"}
	//赋值
	user:=&proto.Teacher{
		Name:"bobby",
		Course:course,
	}
	c.ProtoBuf(http.StatusOK,user)

}

func moreJSON(c *gin.Context) {
	var msg struct {
		//tag定义json是修改默认的key   Name变为user
		Name    string `json:"user"`
		Message string
		Number  int
	}
	msg.Name = "bobby"
	msg.Message = "这是一个测试json"
	msg.Number = 20
	c.JSON(http.StatusOK,msg)
}
